package operation;

import book.Book;
import book.BookList;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: a
 * Date: 2022-04-15
 * Time: 10:03
 */
public class NameCompareOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("按书名排序图书成功!");
        int num=bookList.getUsedSize();
        Book[] books=new Book[num];
        for (int i = 0; i < num; i++) {
            books[i]=bookList.getPos(i);
        }
        NameComparator nameComparator=new NameComparator();
        Arrays.sort(books,nameComparator);
        for (Book book : books) {
            System.out.println(book);
        }
    }
}
